<?php namespace Cribbb\Services\Validators;
 
abstract class Validator {
 
	/**
	 * Post  wanting to validate
	 * @var array
	 */
	protected $input;
	
	protected $errors;
	
	/**
	 * 
	 * @param array $input which will be what we are wanting to validate
	 */
	public function __construct($input = NULL)
	{

		$this->input = $input ?: \Input::all();
	}
	
	/**
	 *
	 * @return boolean
	 */
	public function passes()
	{
		// pass in the $input and a static $rules property which will be in the individual Model’s Validator class.
		$validation = \Validator::make($this->input, static::$rules);
	
		if ($validation->passes())
			return true;
		 
		$this->errors = $validation->messages();
	
		return false;
	}
	
	/**
	 * Simply returns the $errors property because it is protected.
	 */
	public function getErrors()
	{
		return $this->errors;
	}
 
}